package com.atguigu.statistics.controller;

import com.atguigu.commonutils.R;
import com.atguigu.statistics.service.DailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author yky
 * @since 2020-07-18
 */
@RestController
@RequestMapping("/statistics/daily")
@CrossOrigin
public class DailyController {
    @Autowired
    private DailyService dailyService;



    //从ucenter模块中获取注册人数，添加到统计表
    @PostMapping("getNumByDay/{day}")
    public R getNumByDay(@PathVariable("day")String day) {

        dailyService.insertResNum(day);
        return R.ok();
    }

    //条件查询：查什么的数据，按日期降序，日期条件
    @GetMapping("showData/{type}/{begin}/{end}")
    public R showData(@PathVariable("type")String type,
                      @PathVariable("begin")String begin,
                      @PathVariable("end")String end){
        Map<String,Object> map = dailyService.getShowData(type,begin,end);

        return R.ok().data(map);
    }
}

